package com.framework.auth.translator;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class AuthenticationResultHandler extends ResultGeneral implements AccessDeniedHandler, AuthenticationFailureHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) throws IOException {
        outputResult(response, exception);
    }

    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
        outputResult(response, exception);
    }

    public void onParameterFailure(HttpServletRequest request, HttpServletResponse response, Exception exception) throws IOException {
        outputResult(response, exception);
    }
}
